﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 学生成绩管理系统
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            textBox1.Focus();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string username, password;
            string strsql = "";
            DataSet ds;
            if (textBox1.Text.Trim() != "" && textBox2.Text.Trim() != "")
            {
                username = textBox1.Text.Trim();
                password = textBox2.Text.Trim();
                strsql = "select *from Userinfo where Userid='" + username + "'and Userpwd='" + password + "'";
                DataAccess data = new DataAccess();
                data.dataCon();
                ds = data.getDataset(strsql);
                if (ds.Tables[0].Rows.Count == 1)
                {
                    Main main = new Main();
                    main.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误！", "登陆失败");
                }
            }
            else {
                MessageBox.Show("用户名或密码为空，请输入信息","提示");
            }
        }
    }
}
